
#include <QtPlugin>
#include "recaptchafetcher.h"
#include "recaptchafetcher_impl.h"

namespace Wishmaster
{
	RecaptchaFetcher::RecaptchaFetcher() : impl(new RecaptchaFetcherImpl())
	{
		connect(impl.get(), SIGNAL(captcha(ThreadId,QByteArray)), this, SLOT(captcha_result(ThreadId,QByteArray)));
	}

	RecaptchaFetcher::~RecaptchaFetcher()
	{
	}

	QString RecaptchaFetcher::id()
	{
		return "recaptcha";
	}

	CaptchaFetcher* RecaptchaFetcher::clone(Connector* connector, const QVariantMap& params)
	{
		RecaptchaFetcher* fetcher = new RecaptchaFetcher();
		fetcher->impl->setConnector(connector);
		fetcher->impl->setParams(params);
		return fetcher;
	}

	void RecaptchaFetcher::fetchCaptcha(const ThreadId& threadId)
	{
		impl->fetchCaptcha(threadId);
	}

	void RecaptchaFetcher::processRequest(const PostDescriptor& post, const QString& captcha, const RequestPtr& request)
	{
		impl->processRequest(post, captcha, request);
	}

	void RecaptchaFetcher::captcha_result(const ThreadId& id, const QByteArray& arr)
	{
		emit captcha(id, arr);
	}
}

Q_EXPORT_PLUGIN2(recaptchafetcher, Wishmaster::RecaptchaFetcher)

